<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title></title>
    <#include "/jeecms_sys/head.html"/>
    <script src="${base}/thirdparty/swfupload/swfupload.js" type="text/javascript"></script>
    <script src="${base}/thirdparty/swfupload/swfupload.queue.js" type="text/javascript"></script>
    <script src="${base}/thirdparty/swfupload/fileprogress.js" type="text/javascript"></script>
    <script src="${base}/thirdparty/swfupload/handlers.js" type="text/javascript"></script>
    <link href="${base}/thirdparty/swfupload/process.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript">
        $(function() {
            $("#jvForm").validate();
        });
        var swfu;
        window.onload=function() {
            var uploadPicsUrl = "../common/o_swfPicsUpload.do";
            var uploadAttachsUrl = "../common/o_swfAttachsUpload.do";
            //在firefox、chrome下，上传不能保留登录信息，所以必须加上jsessionid。
            var jsessionid = $.cookie("JSESSIONID");
            if(jsessionid) {
                uploadPicsUrl += ";jsessionid="+jsessionid;
                uploadAttachsUrl += ";jsessionid="+jsessionid;
            }

            swfu=new SWFUpload({
                upload_url : uploadPicsUrl,
                flash_url : "${base}/thirdparty/swfupload/swfupload.swf",
                file_size_limit : "20 MB",
                file_types : "*.jpg;*.gif;*.png;*.bmp",
                file_types_description : "<@s.m 'content.picture'/>",
                file_queue_limit : 0,
                custom_settings : {
                    progressTarget : "fsUploadProgress",
                    cancelButtonId : "btnCancel"
                },
                debug: false,

                button_image_url : "${base}/thirdparty/swfupload/button_notext.png",
                button_placeholder_id : "spanButtonPlaceHolder",
                button_text: "<span class='btnText'><@s.m "content.pictures.upload"/></span>",
                    button_width: 84,
                    button_height: 24,
                    button_text_top_padding: 2,
                    button_text_left_padding: 20,
                    button_text_style: '.btnText{color:#666666;}',

                    file_queued_handler : fileQueued,
                    file_queue_error_handler : fileQueueError,
                    file_dialog_complete_handler : fileDialogComplete,
                    upload_start_handler : uploadPicsStart,
                    upload_progress_handler : uploadProgress,
                    upload_error_handler : uploadError,
                    upload_success_handler : uploadPicsSuccess,
                    upload_complete_handler : uploadComplete,
                    queue_complete_handler : queueComplete
        });
        };

        function uploadPicsStart(file) {
            addPicLine();
        }
        var picIndex = 3;
        var picTpl = $.format($("#picTable").val());
        function addPicLine() {
            $('#picBefore').before(picTpl(picIndex++));
        }
        ////

        function uploadAttachStart(file) {
            addAttachLine();
        }
        function uploadAttachSuccess(file,data) {
            var index = attachIndex - 1;
            var jsonData=eval("("+data+")");//转换为json对象
            var attachUrl=jsonData.attachUrl;
            var attachName=jsonData.attachName;
            $("#attachmentPaths"+index).val(attachUrl);
            $("#attachmentNames"+index).val(attachName);
        }
        function uploadPicsSuccess(file,imgUrl) {
            var index = picIndex - 1;
            $("#preImg"+index).attr("src",""+imgUrl);
            var imgSrc = parent.document.getElementById("preImg"+index);
            if(!$(imgSrc).attr("noResize")) {
                $(imgSrc).css("width","auto");
                $(imgSrc).css("height","auto");
            }
            $("#uploadImgPath"+index).val(imgUrl);
        }
    </script>
</head>
<body>
<div class="box-positon">
	<div class="rpos"><@s.m "global.position"/>: <@s.m "product.function"/> - <@s.m "global.add"/></div>
	<form class="ropt">
		<input type="submit" value="<@s.m "global.backToList"/>" onclick="this.form.action='v_list.do';" class="return-button"/>
	</form>
	<div class="clear"></div>
</div>
<div class="body-box">
<#include "/common/image_upload.html"/>
<#assign usernameExist><@s.m "error.usernameExist"/></#assign>
<@p.form id="jvForm" action="o_save.do" labelWidth="12">
<@p.text width="50" colspan="1" label="商品名称" name="productName" value=product.productName required="true" maxlength="100"/>
<@p.select colspan="1" label="商品类别" name="productCateId" value="0"  list=listProductCate listKey="id" listValue="cateName" required="true"/><@p.tr/>

<@p.text width="50" colspan="1" label="招牌主碟" name="mainFood" value=product.mainFood required="true" maxlength="100"/>
<@p.text width="50" colspan="1" label="多彩素菜" name="withFood" value=product.withFood required="true" maxlength="100"/><@p.tr/>

<@p.text width="50" colspan="1" label="鲜绿时蔬" name="beforeFood" value=product.beforeFood required="true" maxlength="100"/>
<@p.text width="50" colspan="1" label="滋养米饭" name="stapleFood" value=product.stapleFood required="true" maxlength="100"/><@p.tr/>

<@p.text width="50" colspan="1" label="蛋白优拼" name="eggWhiteFood" value=product.eggWhiteFood required="true" maxlength="100"/>
<@p.text width="50" colspan="1" label="粗粮小点" name="coarseFood" value=product.coarseFood required="true" maxlength="100"/><@p.tr/>

<@p.text width="50" colspan="1" label="清润卡饮" name="soup" value=product.soup required="true" maxlength="100"/>
<@p.text width="50" colspan="1" label="其它" name="memo1" value=product.memo1 maxlength="100"/><@p.tr/>


<@p.text width="50" colspan="1" label="货号" name="itemNo" value=product.itemNo required="false" maxlength="30" help="如果货号为空系统自动生成"/>
<@p.select colspan="1" label="买十送一" name="canUseTicket"  list={"1":"可以","2","不可以"} required="true"/><@p.tr/>

<@p.text width="50" colspan="1" label="价格" name="price" value=product.price  required="false" maxlength="11"/>
<@p.text width="50" colspan="1" label="积分值" name="score" value=product.score class="digits" required="false" maxlength="11"/><@p.tr/>

<@p.text width="50" colspan="1" label="排序号" name="orderNum" value=product.orderNum maxlength="4" class="digits" help="排序号越大越靠前"/>
<@p.select colspan="2" label="shopInfo.shopName" name="shopId"  list=listShop listKey="id" listValue="shopName" required="true"/><@p.tr/>

<@p.textarea label="一句话介绍"  name="simpleContent" value=product.simpleContent cols="30" rows="2" maxlength="100" colspan="1" width="50"/>
<@p.radio colspan="1"  width="50" label="商品状态" name="status" value=1 list={"1":"上架","-1","下架"} required="true" class="required"/><@p.tr/>

<!-- 批量上传 开始 -->
<@p.td label="批量上传" colspan="2" noHeight="true">
<div>
    <span id="spanButtonPlaceHolder"></span>
    <span style="display: none;"><input class="cancel" id="btnCancel" type="button" value="<@s.m "global.cancel"/>" onclick="swfu.cancelQueue();" disabled="disabled" /></span>
    <div id="fsUploadProgress" style="display: none;"></div>
</div>
<div id="picBefore" style="clear:both"></div>
<textarea id="picTable" style="display:none;">
<table id="picTable{0}" border="0" style="float:left;">
<tr>
    <td>
        <div><input type="text" id="uploadImgPath{0}" name="imgUrls" style="width:160px"/> <a href="javascript:void(0);" onclick="$('#picTable{0}').remove();" class="pn-opt"><@s.m "content.picturesDel"/></a></div>
        <div>
<span id="ufc{0}" style="position:relative">
<input type='text' id='uploadFileText{0}' size="10"/>
<input class="browse" type='button' value='<@s.m "global.browse"/>'/>
<input onchange="$('#uploadFileText{0}').val(this.value)" size="10" type="file" id="uploadFile{0}" class="file-button"/>
</span>
            <input type="button" value="<@s.m "content.fileUpload"/>" onclick="upload({0});" class="upload-button"/>
        </div>图片排序：
        <div><input name="imgOrders" maxlength="255" value="0"/></div>
    </td>
    <td><img id="preImg{0}" alt="<@s.m "imageupload.preview"/>" noResize="true" style="width:110px;height:110px;background-color:#ccc;border:1px solid #333"/></td>
</tr>
</table>
</textarea>
<script type="text/javascript">
    var picIndex = ${product.imgList?size} + 3;
    var picTpl = $.format($("#picTable").val());
    function addPicLine() {
        $('#picBefore').before(picTpl(picIndex++));
    }
</script>
</@p.td>
<!-- 批量上传结束 -->
<@p.tr/>
<!-- 上传图片 -->
<@p.td label="商品图片" colspan="1" width="50" noHeight="true">
<@p.text id="uploadImgPath1" name="imgUrl" value=product.imgUrl style="width:220px"/>
<!--  <input type="button" value="<@s.m "imageupload.preview"/>" onclick="previewImg(1);" class="preview-button"/> --><br/>
<span id="ufc1" style="position:relative">
<input type='text' id='uploadFileText1' size="14"/>
<input class="browse" type='button' value='<@s.m "global.browse"/>'/>
<input onchange="$('#uploadFileText1').val(this.value)" size="14" type="file" id="uploadFile1" class="file-button"/>
</span>
<label><input type="checkbox" onclick="$('#mark1').val(this.checked);"/><@s.m "imageupload.mark"/></label>
<input type="hidden" id="mark1" value="false"/> <input type="button" value="<@s.m "imageupload.upload"/>" onclick="upload(1);" class="upload-button"/><br/>
<@s.m "global.width"/>: <input type="text" id="zoomWidth1" value="100" size="5"/>
<@s.m "global.height"/>: <input type="text" id="zoomHeight1" value="70" size="5"/>
<input type="button" value="<@s.m "imageupload.cut"/>" onclick="imgCut(1);" class="cut-button"/>
</@p.td>
<@p.td colspan="1" width="50">
<img id="preImg1" alt="<@s.m "imageupload.preview"/>" style="width:100px;height:70px;background-color:#CCCCCC;border:1px solid #333"/>
</@p.td><@p.tr/>
<!-- 图片end -->
<@p.editor label="品牌故事" name="content" value=product.content colspan="2"/><@p.tr/>

<@p.td colspan="2"><@p.submit code="global.submit"/> &nbsp; <@p.reset code="global.reset"/></@p.td>
</@p.form>
</div>
<#include "/common/alert_message.html"/>
</body>
</html>